require(['init'], function () {
  var comments=UE.getEditor('comments');
  var id  = location.search.urlToObj().id;
  var schedule  = location.search.urlToObj().schedule;
  var taskid  = location.search.urlToObj().taskid;
  var task  = location.search.urlToObj().task;
  var studentuid = location.search.urlToObj().studentuid;
  var teacheruid = location.search.urlToObj().teacheruid;
  var teachername="";
   $.ajax({
     url:'/api/teacher/'+teacheruid,
     type:'get',
     success:function(data){
       teachername=data.data.lastname;
     }
   })
  //获取老师布置作业和上课的返回信息
     $.ajax({
       url:'/api/task/subject/'+taskid,
       type:'get',
       success:function(data){
         var data=data.data;
         var classeid=data.classeid;
         var scheduleid=data.scheduleid;
          $('.oldcontent').html(data.content);
          $('.title').html(data.title);
          $('.oldnote').html(data.note);
          $('.wrap').find('a').attr('target','_blank');
         $.ajax({
           url:'/api/schedule/'+scheduleid,
           type:'get',
           success:function(datat){
            $.each(datat,function(int,ite){
            $('.lessonname').html(ite.name)

            })

           }
         })
     }
   })

  //h获取学生的答案
  $.ajax({
   url:'/api/task/student/reply',//get /api/task/student/reply
   data:{
     taskid:taskid,
     studentuid:studentuid
   },
   success:function(data){
     $.each(data.data,function(index,item){
       if(item.type==1){
        var replyat;
        if(item.replyat!=null){
         replyat=$.toDate(item.replyat).Format('YYYY-MM-DD hh:mm:ss').substr(11,5);
        }
         $('.currenttime').html(replyat);
         $('<div class="formLi">\
               <div class="formTitle">\
                   <span style="color:#818e9b">'+i18next.t('table.myanswer')+'</span></br>\
                   <span style="color:#818e9b" class="currenttime">'+replyat+'</span>\
               </div>\
               <div class="formContent">\
                   <span class="student_answer">'+item.content+'</span>\
               </div>\
           </div>').appendTo($('.job_content'))
       }else if(item.type==2){
         $('<div class="formLi">\
               <div class="formTitle">\
                   <span style="color:#818e9b">'+i18next.t('table.teacherreplies')+'</span></br>\
                   <span style="color:#818e9b">'+teachername+'</span></br>\
               </div>\
               <div class="formContent">\
                   <span class="student_answer">'+item.content+'</span>\
               </div>\
           </div>').appendTo($('.job_content'))
         }
      })
    }
  })
  $('.wrap').find('a').attr('target','_blank');
  reply_job();
  function reply_job(){
    $('.reply').on('click',function(){
      $('.submit').hide();
      $('.edit').hide();
      $(this).hide();
      var $submit_html=$('#submit_html');
      $submit_html.on('click',function(){
      var content=comments.getContent();
      var popUpBox=new PopUpBox({
        type:'dom',
        style:'default contentScroll',
        submitBtnType:'confirm',
        titleText:i18next.t('table.pleaseaboutclass'),//请约课
        drag:true,
        show:true,
        content:'<div style="margin-top:20px;padding-left:16px;color:#818e9b">'+i18next.t('popupbox.answer')+'</div>',//请确认答案是否正确，提交之后不可更改！
        callback:{
          yes: function (e) {
            ajaxMethod({
              url: '/api/task/reply/'+id+'/commit',  //该id 是作业list产生的作业id
              type: 'put',
              data: {
                content:content,
              },
              success: function (data) {
              window.location.href = "job_title.html?taskid="+taskid+"";
              }
            })
          }
        },
        position:{
          width:446,
          height:265
          }
        })
        $('.confirm').find('.btn-default').css({
         "border": "1px solid #ccc",
        })
      })
    })
  }
})
